﻿@using BootstrapBlazor.Components
@using ThingsGateway.Extension
@using ThingsGateway.Foundation
@using ThingsGateway.Admin.Application
@using ThingsGateway.Admin.Razor
@using ThingsGateway.Gateway.Application
@namespace ThingsGateway.Gateway.Razor


<ValidateForm Model="Model.PluginPropertyModel.Value" 
@key=@($"DeviceEditValidateForm{Model.Id}{Model.PluginPropertyModel.Value.GetType().TypeHandle.Value}")

@ref=Model.PluginPropertyModel.ValidateForm 
Id=@($"DeviceEditValidateForm{Model.Id}{Model.PluginPropertyModel.Value.GetType().TypeHandle.Value}")
>

    <EditorFormObject class="p-2" Items=PluginPropertyEditorItems AutoGenerateAllItem="false" RowType=RowType.Inline ItemsPerRow=2 ShowLabelTooltip=true LabelWidth=250 Model="Model.PluginPropertyModel.Value" @key=@($"DeviceEditEditorFormObject{Model.Id}{Model.PluginPropertyModel.Value.GetType().TypeHandle.Value}")
>

        <FieldItems>
            @if (Model.PluginPropertyModel.Value is BusinessPropertyWithCacheIntervalScript businessProperty)
            {
                <EditorItem FieldExpression=@(()=>context) Field=@(context)>

                    <EditTemplate Context="value">
                        <div class="col-12  col-md-12" style="min-height: 500px;">
                            <BootstrapLabel Value=@BusinessPropertyWithCacheIntervalScriptLocalizer["BigTextScriptDeviceModel"] ShowLabelTooltip="true" />
                            <CodeEditor ShowLineNo @bind-Value=@businessProperty.BigTextScriptDeviceModel Language="csharp" Theme="vs-dark" />
                            <div class="ms-2 d-flex justify-content-center align-items-center">
                                <Button OnClick="()=>CheckScript(businessProperty,nameof(businessProperty.BigTextScriptDeviceModel))">
                                    @Localizer["Check"]
                                </Button>
                            </div>
                        </div>
                        <div class="col-12  col-md-12" style="min-height: 500px;">
                            <BootstrapLabel Value=@BusinessPropertyWithCacheIntervalScriptLocalizer["BigTextScriptVariableModel"] ShowLabelTooltip="true" />
                            <CodeEditor ShowLineNo @bind-Value=@businessProperty.BigTextScriptVariableModel Language="csharp" Theme="vs-dark" />

                            <div class="ms-2 d-flex justify-content-center align-items-center">
                                <Button OnClick="()=>CheckScript(businessProperty,nameof(businessProperty.BigTextScriptVariableModel))">
                                    @Localizer["Check"]
                                </Button>
                            </div>
                        </div>
                        <div class="col-12  col-md-12" style="min-height: 500px;">
                            <BootstrapLabel Value=@BusinessPropertyWithCacheIntervalScriptLocalizer["BigTextScriptAlarmModel"] ShowLabelTooltip="true" />
                            <CodeEditor ShowLineNo @bind-Value=@businessProperty.BigTextScriptAlarmModel Language="csharp" Theme="vs-dark" />

                            <div class="ms-2 d-flex justify-content-center align-items-center">
                                <Button OnClick="()=>CheckScript(businessProperty,nameof(businessProperty.BigTextScriptAlarmModel))">
                                    @Localizer["Check"]
                                </Button>
                            </div>
                        </div>

                    </EditTemplate>
                </EditorItem>
            }
        </FieldItems>
    </EditorFormObject>
</ValidateForm>



